<?php
//后台管理员登录控制器

class ManagerController extends Controller{
    function actions(){
        return array(
            'captcha' => array(
                //路径别名: framework/web/widgets/captcha/CCaptchaAction
                'class'=>'Captcha',
//                'backColor'=>0xFFFFFF,
                'width'=>'60',
                'height'=>'30',
                'maxLength'=>'4',
                'minLength'=>'4',
//                'fixedVerifyCode' => substr(md5(mt_rand(1,10000)),11,4),
            ),
        );
    }
    function actionLogin(){
        $login_model = new LoginForm();

        if(isset($_POST['LoginForm'])){
            $login_model->attributes = $_POST['LoginForm'];

            //用户名密码判断
            //validate校验用户名密码是否为空
            if($login_model->validate() && $login_model->login()){
                $this->redirect('./index.php?r=houtai/index/index');
//                echo "登录成功";
            }
        }
        $processOutput=false;
//render函数内部默认执行processOutput()函数，而renderpartial函数必须制定才会执行
        $this->renderPartial("login",array('login_model'=>$login_model),$return = false,$processOutput= true );
    }

//退出系统
    public  function  actionLogout(){
        //删除session信息
        Yii::app()->session->clear();//删除session内存里面session变量信息
        Yii::app()->session->destroy();//删除服务器的session文件
        Yii::app()->user->logout();//清除浏览器cookies
        $this -> redirect('./index.php?r=houtai/Manager/login');
    }

}